package com.xyy.saas.payment.merchant.core.dto;

import lombok.Builder;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
@Builder
public class QueryReconciliationFileVo {
    /**
     * 记录数
     */
    private String resultNum;
    /**
     * 文件明细
     */
    private List<QueryReconciliationFileItem> fileItems;

    /**
     * 解析明细
     */
    public static List<QueryReconciliationFileItem> parseItems(List<Map<String, String>> param) {
        if(CollectionUtils.isEmpty(param)) {
            return null;
        }

        List<QueryReconciliationFileItem> items = new ArrayList<>();

        for(Map<String, String> item : param) {
            items.add(QueryReconciliationFileItem.builder().
                    fileName(item.get("FileName")).
                    randomPassword(item.get("RandomPassword")).
                    filePath(item.get("FilePath")).
                    drawCode(item.get("DrawCode")).
                    build());
        }

        return items;
    }
}
